<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script type="text/javascript" src="../js/vue.js"></script>
  <title>事件处理</title>
</head>
<body>
  <div id="root">
    <h2>事件处理</h2>
    <hr>
    <!-- <button v-on:click="show">点击输出信息</button> -->
    <!-- 语法糖 -->
    <button @click="show">点击输出信息</button>
    <!-- 传参 -->
    <button @click="show1(value)">点击输出信息2</button>
    <!-- 传参 并且需要 event 对象 -->
    <button @click="show2($event,value)">点击输出信息3</button>
    <hr>
    
    <h2>事件修饰符</h2>
    <a href="http://www.baidu.com" @click.prevent="">点击跳转baidu</a>
    <button @click.stop="">阻止冒泡</button>
    <button @click.once="">只会触发一次事件</button>
  </div>
  <script type="text/javascript">
    Vue.config.productionTip = false 
    const vm = new Vue({
      el: '#root',
      data: {
        name:'Hello'
      },
      methods: {
        show(event) {//默认接收到事件信息
          console.log(event.target);
        },
        show1(value) {
          console.log(value);
        },
        show2(event,value) {
          console.log(event,value);
        }
      }
    })
  </script>
</body>
</html>